#include <cstdio>
#define MAX_U 1005
int father[MAX_U];
int rank[MAX_U];

void init(int N) {

	for (int i = 0; i < N; i++)
	{
		father[i] = i;
		rank[i] = 1;
	}
}


int findFather(int x) {

	while (father[x] != x)
	{
		x = father[x];
		findFather(x);
	}

	return x;
}

int unitGroup(int x, int y) {

	if (x == -1)
	{
		return y;
	}

	int root;
	x = findFather(x);
	y = findFather(y);

	if (x == y)
	{
		return x;
	}

	if (rank[x] < rank[y])
	{
		father[x] = y;
		root = y;
	}
	else
	{
		father[y] = x;
		root = x;
		if (rank[x] == rank[y])
		{
			rank[x]++;
		}
	}

	return root;
}

bool ifGroup(int x, int y) {

	return findFather(x) == findFather(y);

}

int main() {
	int N, M, Q;
	int u[MAX_U], v[MAX_U];
	scanf("%d%d%d",&N,&M,&Q);
	init(N);
	for (int i = 0; i < M; i++)
	{
		scanf("%d%d",&u[i],&v[i]);
	}

	int destory[MAX_U][MAX_U] = { 0 }, ope[MAX_U][3];
	char ch;
	for (int i = 0; i < Q; i++)
	{
		scanf("%c",&ch);
		if (ch == 'P')
		{
			ope[i][0] = 1;
			scanf("%d%d",&ope[i][1], &ope[i][1]);
			destory[ope[i][1]][ope[i][1]] = 1;

		}
		else if (ch == 'Z')
		{
			ope[i][0] = 2;
			scanf("%d", &ope[i][1]);
		}
	}

	for (int i = 0; i < M; i++)
	{
		if (destory[u[i]][v[i]] == 0)
		{
			unitGroup(u[i],v[i]);
		}
	}

	return 0;
}